<?php $this->load->view('admin/header'); ?>
<script src="<?php echo base_url('public/js/bootstrap.file-input.js')?>"></script>
<link href="<?php echo base_url('public/css/bootstrap.file-input.css')?>" rel="stylesheet">

<span>
    <?php echo form_open("Admin/".$to, array('class' => 'form-horizontal')) ?>
        <fieldset>
            <legend>
                <?php
                if (isset($doIt))
                switch ($doIt){
                    case "admin":echo '修改管理员密码';break;
                    case "noAdmin":echo '增加账号';break;
                    case "update":echo '修改账号信息';break;
                }
                ?>
            </legend>
            <?php if (isset($doIt) && $doIt=="admin"):?>
            <div class="control-group">
                <label for="old_password" class="control-label">旧密码</label>
                <div class="controls">
                    <input type="password" title="密码" class="span3" placeholder="请填写密码" id="old_password" data-pattern="^[A-Za-z0-9]{5,}$" name="old_password" value="" data-required="true" data-describedby="old_password-description" data-description="old_password" />
                </div>
            </div>
            <div id="old_password-description"></div>
            <?php endif;?>
            <?php if (isset($doIt) && $doIt=="noAdmin" || $doIt=="update"):?>
            <div class="control-group">
                <label for="User" class="control-label">账号</label>
                <div class="controls">
                    <input type="text" title="账号" class="span3" placeholder="请填写账号" id="User" data-pattern="^[A-Za-z0-9]{5,13}$" name="User" value="<?php echo  isset($work)?$work['userName']:""?>" data-required="true" data-describedby="User-description" data-description="User" <?php echo isset($work)?'readonly':""?>/>
                </div>
            </div>
            <div id="User-description"></div>
            <?php endif;?>

            <div class="control-group">
                <label for="password1" class="control-label">新密码</label>
                <div class="controls">
                    <input type="password" title="密码" class="span3" placeholder="请填写密码" id="password1" data-pattern="^[A-Za-z0-9]{5,}$" name="password1" value="" data-required="true" data-describedby="password1-description" data-description="password1" />
                </div>
            </div>
            
            <div id="password1-description"></div>
            
            <div class="control-group">
                <label for="password2" class="control-label">再次输入</label>
                <div class="controls">
                    <input type="password" title="密码" class="span3" placeholder="请填写密码" id="password2" name="password2" value="" data-required="true" data-describedby="password2-description" data-description="password2" data-conditional="confirm"/>
                </div>
            </div>
            
            <div id="password2-description"></div>
            
            <p class="well">
                <input type="submit" value="<?php echo $doIt=='noAdmin'?'增加':'修改'?>" class="btn btn-primary" id="submit"/>
            </p>
            
        </fieldset>
    </form>
</span>
<script src="<?php echo  base_url('public/js/jquery-validate.min.js') ?>"></script>

<script>
        $('form').validate({
                onKeyup : true,
                eachValidField : function() {

                        $(this).closest('.control-group').removeClass('error').addClass('success');
                },
                eachInvalidField : function() {

                        $(this).closest('.control-group').removeClass('success').addClass('error');
                },
                description : {
                    <?php if ($doIt=="admin"):?>
                    old_password : {
                        required : '<div class="alert alert-error">请填写完毕主要信息</div>',
                        valid : '<div class="alert alert-success">正确</div>',
                        equalTo : '<div class="alert alert-error">请再次输入相同的值</div>'
                    },
                    <?php endif;?>
                    <?php if ($doIt=="noAdmin"):?>
                    User : {
                        required : '<div class="alert alert-error">请填写完毕主要信息</div>',
                        valid : '<div class="alert alert-success">正确</div>',
                        pattern : '<div class="alert alert-error">请填写正确，应为5-13位</div>',
                    },
                    <?php endif;?>
                    password1 : {
                        required : '<div class="alert alert-error">请填写完毕主要信息</div>',
                        valid : '<div class="alert alert-success">正确</div>',
                        pattern : '<div class="alert alert-error">请填写正确，最小长度为5</div>',
                    },
                    password2 : {
                        required : '<div class="alert alert-error">请填写完毕主要信息</div>',
                        valid : '<div class="alert alert-success">正确</div>',
                        equalTo : '<div class="alert alert-error">请再次输入相同的值</div>'
                    }
                },
                conditional : {
			confirm : function() {
				return $(this).val() == $('#password1').val();
			}
		}
        });
</script>
<?php $this->load->view('admin/footer'); ?>

